package com.hogae.capital.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hogae.core.annotation.Log;
import com.hogae.core.core.controller.BaseController;
import com.hogae.core.core.domain.AjaxResult;
import com.hogae.core.enums.BusinessType;
import com.hogae.core.utils.poi.ExcelUtil;

import com.hogae.capital.domain.CapWithdrawalRecord;
import com.hogae.capital.service.ICapWithdrawalRecordService;
import com.hogae.core.core.page.TableDataInfo;

/**
 * 提现记录Controller
 *
 * @author hogae
 * @date 2021-02-26
 */
@Api(tags = "提现记录")
@RestController
@RequestMapping("/capital/withdrawalRecord")
public class CapWithdrawalRecordController extends BaseController {
    @Autowired
    private ICapWithdrawalRecordService capWithdrawalRecordService;

    /**
     * 查询提现记录列表
     */
    @ApiOperation("查询提现记录列表")
    @PreAuthorize("@ss.hasPermi('capital:withdrawalRecord:list')")
    @GetMapping(value = "/list", produces = MediaType.APPLICATION_JSON_VALUE)
    public TableDataInfo list(CapWithdrawalRecord capWithdrawalRecord) {
        startPage();
        List<CapWithdrawalRecord> list = capWithdrawalRecordService.selectCapWithdrawalRecordList(capWithdrawalRecord);
        return getDataTable(list);
    }

    /**
     * 导出提现记录列表
     */
    @ApiOperation("导出提现记录列表")
    @PreAuthorize("@ss.hasPermi('capital:withdrawalRecord:export')")
    @Log(title = "提现记录", businessType = BusinessType.EXPORT)
    @GetMapping(value = "/export", produces = MediaType.APPLICATION_JSON_VALUE)
    public AjaxResult export(CapWithdrawalRecord capWithdrawalRecord) {
        List<CapWithdrawalRecord> list = capWithdrawalRecordService.selectCapWithdrawalRecordList(capWithdrawalRecord);
        ExcelUtil<CapWithdrawalRecord> util = new ExcelUtil<CapWithdrawalRecord>(CapWithdrawalRecord.class);
        return util.exportExcel(list, "withdrawalRecord");
    }

    /**
     * 获取提现记录详细信息
     */
    @ApiOperation("获取提现记录详细信息")
    @PreAuthorize("@ss.hasPermi('capital:withdrawalRecord:query')")
    @GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(capWithdrawalRecordService.selectCapWithdrawalRecordById(id));
    }

    /**
     * 新增提现记录
     */
    @ApiOperation("新增提现记录")
    @PreAuthorize("@ss.hasPermi('capital:withdrawalRecord:add')")
    @Log(title = "提现记录", businessType = BusinessType.INSERT)
    @PostMapping(produces = MediaType.APPLICATION_JSON_VALUE)
    public AjaxResult add(@RequestBody CapWithdrawalRecord capWithdrawalRecord) {
        return toAjax(capWithdrawalRecordService.insertCapWithdrawalRecord(capWithdrawalRecord));
    }

    /**
     * 修改提现记录
     */
    @ApiOperation("修改提现记录")
    @PreAuthorize("@ss.hasPermi('capital:withdrawalRecord:edit')")
    @Log(title = "提现记录", businessType = BusinessType.UPDATE)
    @PutMapping(produces = MediaType.APPLICATION_JSON_VALUE)
    public AjaxResult edit(@RequestBody CapWithdrawalRecord capWithdrawalRecord) {
        return toAjax(capWithdrawalRecordService.updateCapWithdrawalRecord(capWithdrawalRecord));
    }

    /**
     * 删除提现记录
     */
    @ApiOperation("删除提现记录")
    @PreAuthorize("@ss.hasPermi('capital:withdrawalRecord:remove')")
    @Log(title = "提现记录", businessType = BusinessType.DELETE)
    @DeleteMapping(value = "/{ids}", produces = MediaType.APPLICATION_JSON_VALUE)
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(capWithdrawalRecordService.deleteCapWithdrawalRecordByIds(ids));
    }
}
